package com.example.styconsumer.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.example.styinterface.interfaces.IAdminService;
import com.example.styinterface.utils.R;
import com.example.stymodel.model.Admin;

import org.springframework.boot.actuate.autoconfigure.metrics.MetricsProperties;
import org.springframework.stereotype.Repository;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * @author wcq mongoDB学习
 */

@RestController
@RequestMapping("/admin")
public class AdminController {

    @Reference
    private IAdminService adminService;
    //test
    @RequestMapping("/hello")
    public String hello() {
        String hello = adminService.helloAdmin("world");
        System.out.println(hello);
        return hello;
    }
    @PostMapping("/insert")
    public R adminInsert(@RequestBody Admin admin) {

        //todo 换成统一返回结果
        return  adminService.insert(admin);

    }
    @PutMapping("/update")
    public R adminUpdate(@RequestBody Admin admin) {
        return  adminService.update(admin);

    }
    @DeleteMapping("/delete/{id}")
    public R adminDelete(@PathVariable("id") String id) {
        return adminService.delete(id);

    }
    @GetMapping("/selectAll")
    public R adminSelectAll() {
        return adminService.selectAll();
    }
    @GetMapping("/selectOne/{id}")
    public R adminSelectOne(@PathVariable("id") String id) {
        return adminService.selectOne(id);
    }
}